/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dataanalysis.gui.frame;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import javax.swing.Icon;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

/**
 *
 * @author Administrator
 */
public class MainTabPanel extends JTabbedPane {

    public MainTabPanel() {
        this.setTabPlacement(JTabbedPane.BOTTOM);
        this.addChangeListener(new ChangeListener() {

            private Color m_initColor = null;

            public void stateChanged(ChangeEvent e) {
                Container parent = MainTabPanel.this.getParent();
                int n = MainTabPanel.this.getTabCount();
                if (n == 0) {
                    if (parent != null) {
                        if (m_initColor == null) {
                            m_initColor = parent.getBackground();
                        }
                        parent.setBackground(Color.LIGHT_GRAY);
                    }
                } else if (n == 1) {
                    if (parent != null) {
                        parent.setBackground(m_initColor);
                    }
                }
            }
        });
    }

    @Override
    public void insertTab(String title, Icon icon, Component component, String tip, int index) {
        super.insertTab(title, icon, component, tip, index);
        this.setTabComponentAt(index, new ButtonTabComponent(this));
    }
}
